package com.yimi.yinhepda.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.yimi.yinhepda.R;
import com.yimi.yinhepda.entity.bean.AddEntity;
import java.util.List;

/**
 * @author 000432
 * @date 2017/4/10 0010
 *
 * 手动添加的adapter
 */
public class BuildScanByHandAdapter extends BaseAdapter {

  private Context mContext;
  private List<AddEntity> mAddEntityList;

  public BuildScanByHandAdapter(Context context, List<AddEntity> addEntityList) {
    this.mContext = context;
    this.mAddEntityList = addEntityList;
  }

  @Override public View getView(int position, View convertView, ViewGroup viewGroup) {
    ViewHolder viewHolder;
    if (convertView == null) {
      viewHolder = new ViewHolder();
      convertView = LayoutInflater.from(mContext).inflate(R.layout.activity_add_childbillway_listviewitem, null);
      viewHolder.id = (TextView) convertView.findViewById(R.id.sequencynum);
      viewHolder.waybillnum = (TextView) convertView.findViewById(R.id.waybillnum);
      viewHolder.childWaybillnum = (TextView) convertView.findViewById(R.id.childwaybillnum);
      convertView.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) convertView.getTag();
    }
    viewHolder.id.setText(position + "");
    //运单号
    viewHolder.waybillnum.setText(mAddEntityList.get(position).getWaybillNum());
    //子单号
    viewHolder.childWaybillnum.setText(mAddEntityList.get(position).getChildwayBillNum());

    return convertView;
  }

  public static class ViewHolder {
    TextView id;
    /** 运单号 */
    TextView waybillnum;
    /** 开单 */
    TextView childWaybillnum;
  }

  @Override public int getCount() {
    return mAddEntityList != null ? mAddEntityList.size() : 0;
  }

  @Override public Object getItem(int i) {
    return mAddEntityList.get(i);
  }

  @Override public long getItemId(int i) {
    return i;
  }
}
